package Servlets.employer;

import Dao.EmployerDaoimpl;
import Dao.SeekerDaoimpl;
import Entity.Employer;
import Entity.Seeker;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/Emupdate")

public class Emupdate extends HttpServlet {

    private static final long serialVersionUID = 1L;


    public Emupdate() {

        super();
    }
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

// TODO Auto-generated method stub

        request.setCharacterEncoding("UTF-8");

        response.setCharacterEncoding("UTF-8");

        response.setContentType("text/html;charset=UTF-8");

        int eid = (int) request.getSession().getAttribute("seid");
        String ename = request.getParameter("ename");
        String conter =request.getParameter("conter");
        String education = request.getParameter("education");
        String position = request.getParameter("position");
        int renum = Integer.parseInt(request.getParameter("renum"));
        String phone =request.getParameter("phone");

        Employer emif=new Employer(ename,conter,education,position,eid,renum,phone);
        EmployerDaoimpl emer=new EmployerDaoimpl();
        int n=0;

        try {

            n=emer.Change(emif);

        } catch (Exception e) {

// TODO Auto-generated catch block

            e.printStackTrace();

        }
        if(n == 0) {

            request.setAttribute("myinfm", emif);

            request.getRequestDispatcher("employerif.jsp").forward(request, response);

        } else {

            request.setAttribute("myinfm", emif);

            request.getRequestDispatcher("employerif.jsp").forward(request, response);

        }

    }


    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

// TODO Auto-generated method stub

        doGet(request, response);

    }


}